$(function () {  
    // var isPageHide = false;  
    window.addEventListener('pageshow', function(e) {
        // 通过persisted属性判断是否存在 BF Cache
        if (e.persisted && storageControl.getStorageS('refreshs')) {
            storageControl.setStorageS({refreshs:false})
            location.reload();
        }
    });  
}) 
/*
var moreHotelVue = new Vue({
    el:'.morehotelvue',
    data:{
        info:[],
        curtab:9
    },
    methods:{
        getlist:function(e,evt){
            this.curtab = e
        },
        hoteldetail:function(elm){
            var _name = this.info.filter(function(val){
                return val.subclinic_id == elm
            })[0].subclinic_name ;
            window.localStorage.setItem('hotelid',elm+','+_name)
            window.location.href="./hoteldetail.html"
        },
        headersize:function(e){
            var _img = new Image()
            _img.src = e
            _img.onload=function(){
                if(this.width/this.height<=1){
                    return false
                }else{
                    return true
                }
            }
        },
        booking:function(elm){
            var _elm = this.info.filter(function(val){
                return val.subclinic_id == elm
            })[0]
            var _name =_elm.subclinic_name,_go=_elm.isIdle;
            if(_go == 1){
                window.localStorage.setItem('hotelid',elm+','+_name)
                window.location.href="./order.html"
            }else{}
            
        }
    },
    watch:{
        curtab:function(){
            var that = this
            this.noData = this.info.every(function(val){
                return val.booking_status != that.curtab
            })
        } 
    },
    beforeCreate:function(){ 
                                  
        // var that= this            
        // $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getsubclinic',_upDatas,function(res){
        //     if(res.code == 1){
        //         that.curtab =0
        //         for(let i=0;i<res.data.length;i++){
        //             res.data[i].imgsize = ''
        //             baseFn.imgSize({
        //                 rts:0.8,
        //                 imgSrc:res.data[i].subclinic_logo,
        //                 s:function(){
        //                     res.data[i]['imgsize'] = false
        //                 },
        //                 b:function(){
        //                     res.data[i]['imgsize']= true
        //                 }
        //             })
        //             // var _img = new Image()
        //             // _img.src = res.data[i].subclinic_logo
        //             // ss(_img,i)
        //         }
        //         // function ss(dom,ids,rts){
        //         //     dom.onload=function(){
        //         //         if(this.width/this.height <= rts){
        //         //             res.data[ids]['imgsize'] = false
        //         //         }else{
        //         //             res.data[ids]['imgsize']= true
        //         //         }
        //         //     }
        //         // }
        //         that.info = res.data
        //     }
        // },'json')
    },
    created:function(){
        var that= this  
        baseFn.loading.call($('.morehotelvue'),'close')
        baseFn.loading.call($('body'),'close')
        var res={"code":1,"info":"\u83b7\u53d6\u5206\u5e97\u5217\u8868\u6210\u529f","data":[{"subclinic_id":"1","subclinic_name":"\u91d1\u8857\u5206\u90e8","subclinic_logo":"./images/address.jpg","subclinic_phone":null,"subclinic_start_time":"9","subclinic_end_time":"24","subclinic_address":"\u5317\u4eac\u5e02\u987a\u4e49\u533a\u91d1\u8857\u56fd\u9645\u5927\u53a6A\u5ea7402\uff08\u4e2d\u533b\u9662\u5bf9\u9762\u3001\u534e\u8054\u3001\u65b0\u4e16\u754c\u65c1\uff09","subclinic_lat_lon":"40.125996,116.653076","subclinic_desc":"\u7279\u5927\u559c\u8baf\uff0c\u5c0f\u513f\u63a8\u62ff\u5373\u5c06\u4e0e2\u67083\u53f7\u5f00\u542f\u4e13\u5bb6\u95e8\u8bca","subclinic_status":"1","create_time":"2018-03-13 16:28:40","owner_id":"1","distance":"\u672a\u77e5","min":"\u672a\u77e5","userCount":"7","orderCount":"8","isIdle":1,"replyRaion":5},{"subclinic_id":"2","subclinic_name":"\u77f3\u56ed\u5206\u90e8","subclinic_logo":"./images/address.jpg","subclinic_phone":null,"subclinic_start_time":"9","subclinic_end_time":"24","subclinic_address":"\u5317\u4eac\u5e02\u987a\u4e49\u533a\u77f3\u56ed\u4e1c\u533a\u75327\u53f7\u5e95\u5546\uff08\u8054\u901a\u5927\u697c\u5bf9\u9762\u3001\u7f8e\u5ec9\u7f8e\u659c\u5bf9\u9762\uff09","subclinic_lat_lon":"40.109280,116.667790","subclinic_desc":"Hold\u4f4f\u6297\u751f\u7d20\u2014\u2014\u5bbf\u8fc1\u5e02\u4e2d\u533b\u9662\u5c0f\u513f\u63a8\u62ff\u62a4\u4f51\u513f\u7ae5\u5065\u5eb7","subclinic_status":"1","create_time":"2018-03-13 16:28:40","owner_id":"9","distance":"\u672a\u77e5","min":"\u672a\u77e5","userCount":"8","orderCount":"218","isIdle":1,"replyRaion":5},{"subclinic_id":"3","subclinic_name":"\u56fd\u6cf0\u5b8f\u57ce\u5206\u90e8","subclinic_logo":"./images/address.jpg","subclinic_phone":null,"subclinic_start_time":"9","subclinic_end_time":"24","subclinic_address":"\u5317\u4eac\u5e02\u987a\u4e49\u533a\u77f3\u95e8\u56fd\u6cf0\u5b8f\u57ce\u8d2d\u7269\u5e7f\u573a2\u5c42","subclinic_lat_lon":"40.129650,116.635080","subclinic_desc":"\u7279\u5927\u559c\u8baf\uff0c\u5c0f\u513f\u63a8\u62ff\u5373\u5c06\u4e0e2\u67083\u53f7\u5f00\u542f\u4e13\u5bb6\u95e8\u8bca","subclinic_status":"1","create_time":"2018-03-13 16:28:40","owner_id":"50","distance":"\u672a\u77e5","min":"\u672a\u77e5","userCount":"12","orderCount":"104","isIdle":0,"replyRaion":5}]}
        that.curtab =0
        for(let i=0;i<res.data.length;i++){
            res.data[i].imgsize = ''
            baseFn.imgSize({
                rts:0.8,
                imgSrc:res.data[i].subclinic_logo,
                s:function(){
                    res.data[i]['imgsize'] = false
                },
                b:function(){
                    res.data[i]['imgsize']= true
                }
            })
            // var _img = new Image()
            // _img.src = res.data[i].subclinic_logo
            // ss(_img,i)
            if(res.data[i]['isIdle']==0){
                res.data[i]['isIdletxt']='已约满'
            }else{
                res.data[i]['isIdletxt']='空闲可约'
            }
            if(res.data[i]['distance']=="\u672a\u77e5"){
                res.data[i]['distancetxt']="未知"
            }else{
                res.data[i]['distancetxt']=res.data[i]['distance'] +'km'
            }
            if(res.data[i]['min']=="\u672a\u77e5"){
                res.data[i]['mintxt']="未知"
            }else{
                res.data[i]['mintxt']=res.data[i]['distance'] +'min'
            }
        }
        that.info = res.data
    }
})
var moreWorkerVue = new Vue({
    el:'.moreworkervue',
    data:{
        info:[]
    },
    methods:{
        appointment:function(elm,elm2){
            var _hotelname = this.info.filter(function(val){
                return val.subclinic_id == elm2
            })[0].subclinic_name ;
            var _workername = this.info.filter(function(val){
                return val.user_id == elm
            })[0].user_name ;
            // setSession('appointworker',elm+','+_workername)
            // setSession('hotelid',elm2+','+_hotelname)
            storageControl.setStorage({'appointworker':elm+','+_workername,'hotelid':elm2+','+_hotelname})
            // window.location.href='./o)rder.html'
        },
        headersize:function(ids,e){
            var that = this 
            var _img = new Image()
            _img.src = e
            _img.onload=function(){
                if(this.width/this.height<=1){
                    return false
                }else{
                    return true
                }
            }
            // return {'bgimg_hsize':true}
        }
    },
    beforeCreate:function(){
        // var that= this
        // $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getalldoctor',_upDatas,function(res){
        //     if(res.code == 1){
        //         for(let i=0;i<res.data.length;i++){
        //             res.data[i]['imgsize']=''
        //             baseFn.imgSize({
        //                 rts:1,
        //                 imgSrc:res.data[i].user_img,
        //                 s:function(){
        //                     res.data[i]['imgsize'] = false
        //                 },
        //                 b:function(){
        //                     res.data[i]['imgsize']= true
        //                 }
        //             })
        //         }
                
        //         that.info = res.data
        //     }
        // },'json').complete(function(){
        //     baseFn.loading.call($('body'),'close')
        // })
    },
    created:function(){
        if(baseFn.getQueryString('all') == null){
            $('.moreworker_distance').remove()
        }
        var that= this
        // $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getalldoctor',_upDatas,function(res){
            var res = {"code":1,"info":"\u66f4\u591a\u6280\u5e08\u5217\u8868\u6210\u529f","data":[{"subclinic_id":"1","subclinic_name":"\u91d1\u8857\u5206\u90e8","subclinic_phone":null,"subclinic_start_time":"9","subclinic_end_time":"24","subclinic_address":"\u5317\u4eac\u5e02\u987a\u4e49\u533a\u91d1\u8857\u56fd\u9645\u5927\u53a6A\u5ea7402\uff08\u4e2d\u533b\u9662\u5bf9\u9762\u3001\u534e\u8054\u3001\u65b0\u4e16\u754c\u65c1\uff09","subclinic_lat_lon":"40.125996,116.653076","subclinic_desc":"\u7279\u5927\u559c\u8baf\uff0c\u5c0f\u513f\u63a8\u62ff\u5373\u5c06\u4e0e2\u67083\u53f7\u5f00\u542f\u4e13\u5bb6\u95e8\u8bca","subclinic_status":"1","create_time":"2018-02-27 10:04:01","owner_id":"1","user_id":"1","user_no":"GYT000001","user_name":"\u738b\u7acb\u519b[\u6d4b\u8bd5]","user_phone":"13312341230","user_pwd":"e10adc3949ba59abbe56e057f20f883e","user_gender":"1","user_img":"","user_level":"2","user_role":"1","user_status":"0","user_title":"1","work_year":"1","level_type":"1","leave_time":"2018-04-02 21:32:20","user_source":null,"user_desc":null,"simple":"1","integral_count":0,"integral_ave":0,"integral_star":0,"distance":"\u672a\u77e5"},{"subclinic_id":"1","subclinic_name":"\u91d1\u8857\u5206\u90e8","subclinic_phone":null,"subclinic_start_time":"9","subclinic_end_time":"24","subclinic_address":"\u5317\u4eac\u5e02\u987a\u4e49\u533a\u91d1\u8857\u56fd\u9645\u5927\u53a6A\u5ea7402\uff08\u4e2d\u533b\u9662\u5bf9\u9762\u3001\u534e\u8054\u3001\u65b0\u4e16\u754c\u65c1\uff09","subclinic_lat_lon":"40.125996,116.653076","subclinic_desc":"\u7279\u5927\u559c\u8baf\uff0c\u5c0f\u513f\u63a8\u62ff\u5373\u5c06\u4e0e2\u67083\u53f7\u5f00\u542f\u4e13\u5bb6\u95e8\u8bca","subclinic_status":"1","create_time":"2018-03-04 14:05:48","owner_id":"1","user_id":"2","user_no":"GYT000002","user_name":"\u5f20\u8fd0\u6770[\u6d4b\u8bd5]","user_phone":"13312341231","user_pwd":"497b0b739264846ee04d26bd21013091","user_gender":"1","user_img":"","user_level":"3","user_role":"2","user_status":"0","user_title":"1","work_year":"1","level_type":"1","leave_time":"2018-04-26 14:03:02","user_source":"\u62db\u80582","user_desc":null,"simple":0,"integral_count":0,"integral_ave":0,"integral_star":0,"distance":"\u672a\u77e5"}]}
            if(res.code == 1){
                for(let i=0;i<res.data.length;i++){
                    res.data[i]['imgsize'] = false
                    if(res.data[i].user_img != ''){
                        // res.data[i]['imgsize']=''
                        baseFn.imgSize({
                            rts:1,
                            imgSrc:res.data[i].user_img,
                            s:function(){
                                res.data[i]['imgsize'] = false
                            },
                            b:function(){
                                res.data[i]['imgsize']= true
                            }
                        })
                    }
                    if(res.data[i]['distance']=="\u672a\u77e5"){
                        res.data[i]['distancetxt']="距离未知"
                    }else{
                        res.data[i]['distancetxt']=res.data[i]['distance'] +'km'
                    }
                    if(res.data[i]['user_desc'] == null){
                        res.data[i]['user_desc'] = '暂无介绍'
                    }
                    if(res.data[i]['user_title'] == "1"){
                        res.data[i]['user_titletxt'] = '中医调理师'
                    }else{
                        res.data[i]['user_titletxt'] = '调理师'
                    }
                    if(res.data[i]['work_year'] == "1"){
                        res.data[i]['work_yeartxt'] = '十五'
                    }else{
                        res.data[i]['lwork_yeartxt'] = '一'
                    }
                    if(res.data[i]['level_type'] == "1"){
                        res.data[i]['level_typetxt'] = '优秀大夫'
                    }else{
                        res.data[i]['level_typetxt'] = '厉害大夫'
                    }
                    if(res.data[i]['user_level'] == "3"){
                        res.data[i]['user_levelName']='副院长'
                    }else{
                        res.data[i]['user_levelName']='职工'
                    }
                    
                }
                that.info = res.data
            }
        // },'json').complete(function(){
        //     baseFn.loading.call($('body'),'close')
        // })
    }
})
*/
//评价
if($('.evaluatevue').length == 1){
    if(isExitStorage('orderid')){
        var _orderid = window.localStorage.getItem('orderid'),
        _upDatas={booking_id:_orderid}
    }else{
        baseFn.popShow({
            txt:'请选择具体订单',
            ok:function(){
                window.history.back()
            },
            timeable:true,
            time:1000,
        })
        var _upDatas={}
    }
    var evalVue = new Vue({
        el:'.evaluatevue',
        data:{
            info:{
                doctor_img:'',
                doctor_name:'',
                reply_integral:'',
                reply_info:'',
                status:'',
                doctor_id:'',
                user_id:'',
                user_name:'',
                doctor_img:'',
                imgsize:false,
                reply_integral1:'',
                reply_info1:'',
                status1:'',
                reply_integral2:'',
                reply_info2:'',
                status2:'',
                reply_integral3:'',
                reply_info3:'',
                status3:'',
            }
        },
        methods:{
            appointment:function(elm,elm2){
                var _hotelname = this.info.filter(function(val){
                    return val.hid == elm2
                })[0].hname ;
                var _workername = this.info.filter(function(val){
                    return val.id == elm
                })[0].name ;
                storageControl.setStorage({'appointworker':elm+','+_workername,'hotelid':elm2+','+_hotelname})
                // setSession('appointworker',elm+','+_workername)
                // setSession('hotelid',elm2+','+_hotelname)
                // window.location.href='./order.html'
            },
            tabstar:function(elm,ids){
                var type=['','非常不满意，各方面都很差','不满意，比较差','一般，还需要改善','比较满意，仍可改善','非常满意，无可挑剔']
                if(ids == 0){
                    this.info.status=type[elm];
                    this.info.reply_integral=elm;
                }else{
                    this.info['status'+ids]=type[elm];
                    this.info['reply_integral'+ids]=elm;
                }
            },
            check(){
                var _upData={
                    booking_id: _orderid,
                    doctor_id: this.info.doctor_id,
                    user_id: this.info.user_id,
                    user_name: this.info.user_name,
                    reply_integral: this.info.reply_integral,
                    reply_info: this.info.reply_info
                }
                if(this.info.reply_integral == ''){
                    baseFn.popShow({
                        txt:'您还没有评价哦，请完成评价。'
                    })
                    return false;
                }
                if(this.info.reply_info == ''){
                    _upData.reply_info = this.info.status 
                }
                
                // console.log(_upData)
                // return false;
                $.post('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/setreply',_upData,function(res){
                    baseFn.popShow({
                        txt:res.info,
                        ok:function(){
                            window.history.back()
                        }
                    })
                },'json')
            }
        },
        computed:{
            reply_x_integral:function(){
                if(this.info.reply_integral == ''){
                    return '0'
                }
                return this.info.reply_integral+'.0'
            },
            reply_x_integral1:function(){
                if(this.info.reply_integral1 == ''){
                    return '0'
                }
                return this.info.reply_integral1+'.0'
            },
            reply_x_integral2:function(){
                if(this.info.reply_integral2 == ''){
                    return '0'
                }
                return this.info.reply_integral2+'.0'
            },
            reply_x_integral3:function(){
                if(this.info.reply_integral3 == ''){
                    return '0'
                }
                return this.info.reply_integral3+'.0'
            }
        },
        beforeCreate:function(){
            var that= this
            $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getservice',_upDatas,function(res){
                if(res.code == 1){
                    that.info.doctor_name=res.data.doctor_name
                    that.info.doctor_img=res.data.doctor_img
                    that.info.doctor_id=res.data.doctor_id
                    that.info.user_id=res.data.user_id
                    that.info.user_name=res.data.user_name
                    baseFn.imgSize({
                        rts:1,
                        imgSrc:res.data.doctor_img,
                        s:function(){
                            that.info.imgsize = false
                        },
                        b:function(){
                            that.info.imgsize = true
                        }
                    })
                }
            },'json').complete(function(){
                baseFn.loading.call($('body'),'close')
            })
        },
        created:function(){
            
        }
    })
}
// if(baseFn.getQueryString('temp') && baseFn.getQueryString('temp') == 1){
//     history.pushState('', "order", "./order.html");
//     window.location.reload()
// }
// 门店详情
if($('.hoteldetailvue').length == 1){
    var _hotelDetailUpDatas = {}
    if(isExitStorage('hotelid')){
        _hotelDetailUpDatas.subclinic_id = storageControl.getStorage('hotelid').split(',')[0]
    }
    if(isExitStorage('latlng')){
        _hotelDetailUpDatas.lat = storageControl.getStorage('latlng')[0]
        _hotelDetailUpDatas.lng = storageControl.getStorage('latlng')[1]
    }
    // 门店详细 
    if(storageControl.isExitStorage('hotelid')){
        var _upCallDatas={
            subclinic_id:_upDatas.subclinic_id,
            ad_type:'1'
        }
        var moreWorkerVue = new Vue({
            el:'.hoteldetailvue',
            data:{
                info:{}
            },
            methods:{
                hoteldetail:function(elm){
                    var _name = this.info.filter(function(val){
                        return val.subclinic_id == elm
                    })[0].subclinic_name ;
                    window.localStorage.setItem('hotelid',elm+','+_name)
                }
            },
            beforeCreate:function(){
                var that= this
                $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getsubclinic',_upDatas,function(res){
                    if(res.code == 1){
                        // console.log(res.data[0])
                        baseFn.loading.call($('body'),'close')
                        that.info = res.data
                    }
                },'json').complete(function(){
                    baseFn.loading.call($('body'),'close');
                    baseFn.loading.call($('.hoteldetailvue'),'close')
                })
            },
            created:function(){
                
            }
        })
        // $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getadvert',_upCallDatas,function(res){
        //     if(res.data.length != 0){
        //         $('.gblink').attr('href',res.data[0].skip_url).append('<marquee>'+res.data[0].ad_name+'</marquee>')
                
        //     }else{
        //         $('.gblink').attr('href','javascript:void(0)').append('暂无广播')
        //     }
            
        // },'json')   
    }else{
        baseFn.popShow({
            txt:'请选择具体门店',
            timeable:true,
            time:1000,
            ok:function(){
                window.location.assign('./index.html')
            }
        })
    }
    $('.dev1 .txt').text('文字')
    $('.dev2 .txt').text('文字')
    $('.dev3 .txt').text('文字')
    baseFn.infoimg({
        apDom:'.dev1',
        data:[  {url:'images/banner.jpg'},
                {url:'images/publicistpage/com_banner1.jpg'},
                {url:'images/publicistpage/com_banner2.jpg'},
                {url:'images/publicistpage/com_banner3.jpg'},
                {url:'images/bg.jpg'}]
    })
    baseFn.infoimg({
        apDom:'.dev2',
        data:[  {url:'images/banner.jpg'},
                {url:'images/publicistpage/com_banner1.jpg'},
                {url:'images/publicistpage/com_banner2.jpg'},
                {url:'images/publicistpage/com_banner3.jpg'},
                {url:'images/bg.jpg'}]
    })
    baseFn.infoimg({
        apDom:'.dev3',
        data:[  {url:'images/banner.jpg'},
                {url:'images/publicistpage/com_banner1.jpg'},
                {url:'images/publicistpage/com_banner2.jpg'},
                {url:'images/publicistpage/com_banner3.jpg'},
                {url:'images/bg.jpg'}]
    })

}
// 更多医师 无地理位置
if($('.moreworkervue').length == 1 && baseFn.getQueryString('all') != null){
    if(isExitStorage('hotelid')){
        var _hotelid = window.localStorage.getItem('hotelid').split(',')[0],
        _upDatas={subclinic_id:_hotelid}
    }else{
        var _upDatas={}
    }
    var moreWorkerVue = new Vue({
        el:'.moreworkervue',
        data:{
            info:[]
        },
        methods:{
            appointment:function(elm,elm2){
                var _hotelname = this.info.filter(function(val){
                    return val.subclinic_id == elm2
                })[0].subclinic_name ;
                var _workername = this.info.filter(function(val){
                    return val.user_id == elm
                })[0].user_name ;
                // setSession('appointworker',elm+','+_workername)
                // setSession('hotelid',elm2+','+_hotelname)
                storageControl.setStorage({'appointworker':elm+','+_workername,'hotelid':elm2+','+_hotelname})
                // window.history.back()
                // window.location.href='./order.html'
            },
            headersize:function(ids,e){
                var that = this 
                var _img = new Image()
                _img.src = e
                _img.onload=function(){
                    if(this.width/this.height<=1){
                        return false
                    }else{
                        return true
                    }
                }
                // return {'bgimg_hsize':true}
            }
        },
        beforeCreate:function(){
            var that= this
            $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getdoctor',_upDatas,function(res){
                if(res.code == 1){
                    for(let i=0;i<res.data.length;i++){
                        res.data[i]['imgsize']=''
                        baseFn.imgSize({
                            rts:1,
                            imgSrc:res.data[i].user_img,
                            s:function(){
                                res.data[i]['imgsize'] = false
                            },
                            b:function(){
                                res.data[i]['imgsize']= true
                            }
                        })
                    }
                    
                    that.info = res.data
                }
            },'json').complete(function(){
                baseFn.loading.call($('body'),'close')
            })
        },
        created:function(){
            if(baseFn.getQueryString('all') == null){
                $('.moreworker_distance').remove()
            }
        }
    })
}
// 选择患者
if($('.morepatientvue').length == 1){
    var patientsVue = new Vue({
        el:'.morepatientvue',
        data:{
            info:[]
        },
        methods:{
            addpatientInfo:function(elm,elm2){
                // console.log(elm)
                storageControl.setStorage({patientInfo:JSON.stringify(elm)})
                window.history.back()
                // window.location.href='./order.html'
            }
        },
        beforeCreate:function(){
            var _userData={
                user_id:storageControl.getStorage('userId')
                // user_id:1
            }
            var that=this;
            $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getbookinginfo',_userData,function(res){
                if(res.code==1){
                    var _data = res.data.patientInfo
                    if(baseFn.notNull(_data)){
                        for(let i=0;i<_data.length;i++){
                            _data[i]['imgsize']=''
                            baseFn.imgSize({
                                rts:1,
                                imgSrc:_data[i].user_img,
                                s:function(){
                                    _data[i]['imgsize'] = false
                                },
                                b:function(){
                                    _data[i]['imgsize']= true
                                }
                            })
                        }
                        that.info = _data
                    }
                }else{
                    alert('数据错误！')
                }
                
                
            },'json').complete(function(){
                baseFn.loading.call($('body'),'close')
            })
        },
        created:function(){
            if(baseFn.getQueryString('all') == null){
                $('.moreworker_distance').remove()
            }
        }
    })
}
//轮播图和广播
if($('.layoutvue').length == 1){   
    if(storageControl.isExitStorage('hotelid')){ 
        var _hotelid = storageControl.getStorage('hotelid').split(',')[0],
        _upDatas={
            subclinic_id:_hotelid,
            ad_type:'0'
        },_upCallDatas={
            subclinic_id:_hotelid,
            ad_type:'1'
        }
    }else{
        var _upDatas={
            subclinic_id:'3',
            ad_type:'0'
        },_upCallDatas={
            subclinic_id:'3',
            ad_type:'1'
        }
    }
    var layoutVue = new Vue({
        el:'.layoutvue',
        data:{
            info:[],
            count:0
        },
        watch:{
        },
        beforeCreate:function(){
            var that=this
            $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getadvert',_upDatas,function(res){
                var _data=[]
                if(res.code=='0'){
                }else{
                    _data=res.data
                    that.count=_data.length
                    var _tempInfo = []
                    for(var i=0;i<_data.length;i++){
                        _tempInfo.push(_data[i])
                    }
                    _tempInfo.unshift(_data[_data.length-1])
                    _tempInfo.push(_data[0])
                    that.info=_tempInfo;
                }    
            },'json').complete(function(res){
            })
        },
        created:function(){          
        },
        mounted:function(){
        },
        updated:function(){
            var imageCount = this.count; //页面中用来轮播的图片有5张不同的
            //轮播图大盒子
            var banner = document.querySelector('.banner');
            //图片的宽度
            var width = banner.offsetWidth;
            //图片盒子
            var imageBox = banner.querySelector('.banimg');
            //点盒子
            var pointBox = banner.querySelector('.banpoint');
            //所有的点
            var points = pointBox.querySelectorAll('li');

            //公用方法
            //加过渡
            var addTransition = function(){
                imageBox.style.transition = "all 0.3s";
                imageBox.style.webkitTransition = "all 0.3s";/*做兼容*/
            };
            //清除过渡
            var removeTransition = function(){
                imageBox.style.transition = "none";
                imageBox.style.webkitTransition = "none";
            }
            //定位
            var setTranslateX = function(translateX){
                imageBox.style.transform = "translateX("+translateX+"px)";
                imageBox.style.webkitTransform = "translateX("+translateX+"px)";
            }

            //功能实现
            //自动轮播  定时器  无缝衔接  动画结束瞬间定位
            var index = 1;
            var timer = setInterval(function(){
                index++ ;   //自动轮播到下一张
                //改变定位  动画的形式去改变  transition transform translate
                addTransition();    //加过渡动画
                setTranslateX(-index * width);  //定位
            },3000);

            //等过渡结束之后来做无缝衔接
            my.transitionEnd(imageBox, function(){
                //处理事件结束后的业务逻辑
                if(index > imageCount ){
                    index = 1;
                }else if(index <= 0){
                    index = imageCount;
                }
                removeTransition(); //清除过渡
                setTranslateX(-index * width);  //定位
                setPoint(); //设置底部显示当前图片对应的圆角
            });

            //改变当前样式  当前图片的索引
            var setPoint = function(){
                //清除上一次的now
                for(var i = 0 ; i < points.length ; i++){
                    points[i].className = " ";
                }
                //console.log(points[index-1])
                //给图片对应的点加上样式
                points[index-1].className = "now";
            }

            /*
            手指滑动的时候让轮播图滑动   touch事件  记录坐标轴的改变 改变轮播图的定位（位移css3）
            当滑动的距离不超过一定的距离的时候  需要吸附回去  过渡的形式去做
            当滑动超过了一定的距离  需要 跳到 下一张或者上一张  （滑动的方向） 一定的距离（屏幕的三分之一）
            */
            //touch事件
            var startX = 0; //记录起始  刚刚触摸的点的位置 x的坐标
            var moveX = 0;  //滑动的时候x的位置
            var distanceX = 0;  //滑动的距离
            var isMove = false; //是否滑动过
            var startTime = 0;
            var endTime=0
            imageBox.addEventListener('touchstart', function(e){
                clearInterval(timer);   //清除定时器
                startX = e.touches[0].clientX;  //记录起始X
                startTime = Date.parse(new Date())
                endTime = Date.parse(new Date())
            });

            imageBox.addEventListener('touchmove',function(e){
                moveX = e.touches[0].clientX;   //滑动时候的X
                distanceX = moveX - startX; //计算移动的距离
                //计算当前定位  -index*width+distanceX
                removeTransition(); //清除过渡
                setTranslateX(-index * width + distanceX);  //实时的定位
                isMove = true;  //证明滑动过
                endTime = Date.parse(new Date())
            });

            //在模拟器上模拟的滑动会有问题 丢失的情况  最后在模拟器的时候用window
            imageBox.addEventListener('touchend', function(e){
                // 滑动超过 1/3 即为滑动有效，否则即为无效，则吸附回去
                if(isMove && (Math.abs(distanceX) > width/3 || ((endTime-startTime)<400 && (endTime-startTime) != 0))){
                    //5.当滑动超过了一定的距离  需要 跳到 下一张或者上一张  （滑动的方向）*/
                    if(distanceX > 0){  //上一张
                        index --;
                    }
                    else{   //下一张
                        index ++;
                    }
                }
                addTransition();    //加过渡动画
                setTranslateX(-index * width);    //定位

                if(index > imageCount ){
                    index = 1;
                }else if(index <= 0){
                    index = imageCount;
                }
                setPoint();

                //重置参数
                startX = 0;
                moveX = 0;
                distanceX = 0;
                isMove = false;
                //加定时器
                clearInterval(timer);   //严谨 再清除一次定时器
                timer= setInterval(function(){
                    index++ ;  //自动轮播到下一张
                    addTransition();    //加过渡动画
                    setTranslateX(-index * width);    //定位
                },3000);
            });
        }
    })
    $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getadvert',_upCallDatas,function(res){
        if(res.data.length != 0){
            $('.gblink').attr('href',res.data[0].skip_url).append('<marquee style="vertical-align:-1px;">'+res.data[0].ad_name+'</marquee>')
            var imgh='auto 100%'
            baseFn.imgSize({
                rts:0.8,
                imgSrc:res.data[0].ad_image,
                s:function(){
                    //比rts小
                    imgh='auto 100%'
                },
                b:function(){
                    //比rts大
                    imgh='100% auto'
                },
                calFn:function(){
                    baseFn.popShow({
                        popdom:'.pop.index',
                        txt:'<div class="popimg" style="background-image:url('+res.data[0].ad_image+')">\
                            </div>\
                            <p class="poptxt gbpoptxt nowrap">'+res.data[0].ad_name+'</p>'
                    })
                    $('.pop.index img').css('backgroud-size',imgh)
                }
            })
            // console.log($('marquee').width())
        }else{
            $('.gblink').attr('href','javascript:void(0)').append('孩子的每一点健康，都是您坚持的结果。')
        }
        
    },'json')
}
//会员中心
if($('.vipervue').length == 1){
    var vipers = new Vue({
        el:'.vipervue',
        data:{
            info:{
                user_phone:'13800000000',
                user_level:'2',
                user_img:'',
                imgsize:true
            }
        },
        computed:{
            user_x_phone:function(){
                return this.info.user_phone.substring(0,3)+'****'+this.info.user_phone.substring(7)
            }
        },
        methods:{
        },
        beforeCreate:function(){
            var e = 1,that = this
            var _upData = {
                user_id:storageControl.getStorage('userId')
            }
            $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getuser',_upData,function(res){
                // res.data.user_img='https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2043305675,3979419376&fm=200&gp=0.jpg'
                res.data.imgsize = false
                baseFn.imgSize({
                    rts:1,
                    imgSrc:res.data.user_img,
                    s:function(){
                        that.info.imgsize = false
                    },
                    b:function(){
                        that.info.imgsize = true
                    }
                })
                
                if(!res.data.user_phone || res.data.user_phone == null || res.data.user_phone == undefined){
                    res.data.user_phone = 13800000000
                }
                that.info = res.data
            },'json').complete(function(){
                baseFn.loading.call($('body'),'close')
            })
        },
        created:function(){
            // var e = 1,that = this
            // var res={"code":1,"info":"\u83b7\u53d6\u4f1a\u5458\u8d44\u6599\u6210\u529f","data":{"user_id":"1","open_id":null,"user_name":"\u90ed\u96e8\u676d","user_phone":"15910444447","user_phones":null,"phone_code":null,"user_img":"./images/vipphone.jpg","user_account":"1100.00","user_level":"1","user_birthday":"2007-11-06","user_gender":"0","user_from":"1","user_address":null,"subclinic_id":null,"user_wx":null,"create_time":"2018-04-30 23:59:59","width":null,"height":null,"grade_name":"\u521d\u7ea7\u4f1a\u5458","grade_img":null,"cards":"0","coupons":"0"}}
            // res.data.imgsize = false
            // baseFn.imgSize({
            //     rts:1,
            //     imgSrc:res.data.user_img,
            //     s:function(){
            //         that.info.imgsize = false
            //     },
            //     b:function(){
            //         that.info.imgsize = true
            //     }
            // })
            
            // if(!res.data.user_phone || res.data.user_phone == null || res.data.user_phone == undefined){
            //     res.data.user_phone = 13800000000
            // }
            // that.info = res.data
        }
    })
}  
//会员订单列表
if($('.viplistvue').length == 1){
    function setCancel(d){
        $.post('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/cancal',{booking_id:moreWorkerVue.cancelbooking,cancelType:d},function(res){
            if(res.code=='1'){
                var _upData={}
                baseFn.popShow({
                    txt:res.info,
                    ok:function(){
                        _upData.user_id=storageControl.getStorage('userId')
                        $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getbooking',_upData,function(res){
                            moreWorkerVue.info = res.data
                            moreWorkerVue.cancelbooking = ''
                        },'json')
                    },
                    timeable:true
                })  
            }
        },'json')
    }
    function cancelgo(){
        $('.cancelorder').removeClass('active')
        $('.mark').removeClass('active')
    }
    var moreWorkerVue = new Vue({
        el:'.viplistvue',
        data:{
            info:[],
            curtab:9,
            noData:true,
            cancelbooking:''
        },
        methods:{
            getlist:function(e,evt){
                this.curtab = e
            },
            setListid:function(ids){
                storageControl.setStorage({'orderid':ids})
            },
            showState:function(e){
                if(e == '1'){
                    return '已完成'
                }else if(e == '2'){
                    return '已取消'
                }else if(e == '0'){
                    return '已预约'
                }else if(e == '3'){
                    return '待评价'
                }
            },
            detailurl:function(e){
                if(e==1){
                    return './orderlistvue.html';
                }else{
                    return 'javascript:void(0)';
                }
            },
            cancelorder:function(e){
                // var that = this
                $('.cancelorder').addClass('active')
                $('.mark').addClass('active')
                this.cancelbooking=e
                // $.post('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/cancal',{booking_id:e},function(res){
                    
                //     if(res.code=='1'){
                //         var _upData={}
                //         baseFn.popShow({
                //             txt:res.info,
                //             ok:function(){
                //                 _upData.user_id=storageControl.getStorage('userId')
                //                 $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getbooking',_upData,function(res){
                //                     that.info = res.data
                //                 },'json')
                //             },
                //             timeable:true
                //         })

                        
                //     }
                // },'json')
            }
        },
        watch:{
            curtab:function(){
                var that = this
                //这里要有接口支持
            } 
        },
        beforeCreate:function(){
            var e = 1,that = this
            var _upData = {
                user_id:storageControl.getStorage('userId')
            }
            baseFn.loading.call($('.viplistvue'),'close')
            $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getbooking',_upData,function(res){
                that.curtab =0
                that.info = res.data
                baseFn.loading.call($('.viplistvue'),'close')
            },'json').complete(function(){
                baseFn.loading.call($('body'),'close')
            })
        }
    })
}   
//订单详情
if($('.orderlistvue').length == 1){
    if(isExitStorage('orderid')){
        var _orderid = window.localStorage.getItem('orderid'),
        _upDatas={booking_id:_orderid}
    }else{
        baseFn.popShow({
            txt:'请选择具体订单',
            ok:function(){
                window.location.assign('./vip.html')
            },
            timeable:true,
            time:2000
        })
        var _upDatas={}
    }
    var moreWorkerVue = new Vue({
        el:'.orderlistvue',
        data:{
            info:{}
        },
        methods:{
            hoteldetail:function(elm){
                var _name = this.info.filter(function(val){
                    return val.subclinic_id == elm
                })[0].subclinic_name ;
                window.localStorage.setItem('hotelid',elm+','+_name)
            }
        },
        beforeCreate:function(){
            var that= this
            $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/orderinfo',_upDatas,function(res){
                if(res.code == 1){
                    that.info = res.data
                }
            },'json').complete(function(){
                baseFn.loading.call($('body'),'close')
            })
        },
        created:function(){
        }
    })
}
//用户设置
if($('.usettingvue').length == 1){
    var images = {
        localId: [],
        serverId: []
    };
    var user = new Vue({
        el:'.usettingvue',
        data:{
            info:{
                user_phone:'13800000000',
                user_level:'2',
                user_img:'',
                width:10,
                height:10
            }
        },
        computed:{
            imgsize:function(){
                return (this.info.width/this.info.height >= 1)
            }
        },
        methods:{
            check:function(){
                var _txt=''
                if(this.info.user_name == ''){
                    _txt = '您的姓名还没有填写'
                }
                if(_txt != ''){
                    baseFn.popShow({
                        txt:_txt,
                        ok:function(){
                        }
                    })
                    return false;
                }
                var _upDatas={
                    'user_id':storageControl.getStorage('userId'),
                    'user_img':this.info.user_img,
                    'width':this.info.width,
                    'height':this.info.height,
                    'user_name':this.info.user_name,
                    'user_gender':this.info.user_gender,
                    'user_birthday':this.info.user_birthday

                }
                // var pic=["images/gif", "images/jpeg", "images/jpg", "images/bmp", "images/png"]
                // var fileType = String(document.getElementById('upfile').files[0].type)
                // if(pic[0] == fileType || pic[1] == fileType){
                    $.ajax({
                        // url:'',
                        url:'http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/setuser',
                        type:"POST",
                        data:_upDatas,
                        // cache: false,
                        // contentType: false,  
                        // processData: false,
                        dataType:"json",
                        success:function(res){
                            baseFn.popShow({
                                txt:res.info,
                                ok:function(){
                                    if(res.code == 1){
                                        window.location.assign("./vip.html")
                                    }
                                }
                            })
                            
                        },
                        complete:function(res){
                        },
                        error:function(res){
                        }    
                    })
                // }else{
                //     alert('文件格式不对！')
                // } 
            },
            imgupwx:function(){
                var that= this
                wx.chooseImage({
                    count: 1,
                    sizeType: ['compressed'],
                    success: function (res) {
                        console.log(res)
                        that.info.user_img = res.localIds[0]
                        $('#upfile').val(res.localIds[0])
                    },
                    fail:function(){
                    }
                });
            },
            imgup:function(){
                $('#upfile').trigger('click')
            }
        },
        beforeCreate:function(){
            var that = this
            var _upData = {
                user_id:storageControl.getStorage('userId')
            }
            $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getuser',_upData,function(res){
                that.info = res.data
            },'json')
        },
        created:function(){
        },
        mounted:function(){
            // console.log($('.filebtn').length)
        /*    $('.filebtn').on('change',function(){
                var _file = $(this)[0].files[0]
                // console.log(_file)
                var _reader = new FileReader();
                _reader.onload = function() {
                    $('.upimg').attr('src',_reader.result)
                    this.urls = _reader.result
                  };
                  _reader.readAsDataURL(this.files[0]);
                // var _url=''
                // if (window.createObjectURL != undefined) {
                //     _url = window.createObjectURL(_file);
                // } else if (window.URL != undefined) {
                //     _url = window.URL.createObjectURL(_file);
                // } else if (window.webkitURL != undefined) {
                //     _url = window.webkitURL.createObjectURL(_file);
                // }
                // $('.upimg').attr('src',_url)
                // this.urls = _url
            })
        */
        var that =this
            $('.filebtn').on('change',function(){
                var formDataPic = new FormData(document.getElementById('importexform'))
                $.ajax({
                    url:'http://47.92.39.186/xrtn-manager/imgUploadCtl/imgUpload',
                    type:"POST",
                    data:formDataPic,
                    cache: false,
                    contentType: false,  
                    processData: false,
                    dataType:"json",
                    success:function(res){
                        if(res.status == 'error'){
                            baseFn.popShow({
                                txt:'头像上传失败，请重试',
                                ok:function(){
                                }
                            })
                        }else if(res.status == 'success'){
                            that.info.user_img = res.url
                            that.info.width = res.width
                            that.info.height = res.height
                        } 
                    },
                    complete:function(res){
                    },
                    error:function(res){
                    }    
                })
            })
        }
    })
    
    
}
//优惠券
if($('.couponvue').length == 1){
    var couponvue = new Vue({
        el:'.couponvue',
        data:{
            info:[]
        },
        methods:{
            couponType:function(e){
                var _color = '#e7e7e7'
                if(e == '通用券'){
                    _color = '#008DED'
                }else if( e == '满减券'){
                    _color = '#21D0A9'
                }else if( e == '体验券'){
                    _color = '#F8841C'
                }
                return _color
            }
        },
        beforeCreate:function(){
            var that = this
            var _upData = {
                user_id:storageControl.getStorage('userId')
            }
            $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getcoupon',_upData,function(res){
                if(res.code == '1'){
                    for(let i=0;i<res.data.length;i++){
                        res.data[i]['imgsize'] = true
                        baseFn.imgSize({
                            rts:1,
                            imgSrc:res.data[i].card_img,
                            s:function(){
                                res.data[i]['imgsize'] = false
                            },
                            b:function(){
                                res.data[i]['imgsize']= true
                            }
                        })
                    }
                    that.info = res.data
                    
                }else{
                    baseFn.popShow({
                        txt:res.info,
                        ok:function(){
                            window.location.assign('./vip.html')
                        }
                    })
                }
            },'json').complete(function(){
                baseFn.loading.call($('body'),'close')
            })
        },
        created:function(){
        }
    })
}
//计次卡
if($('.countvue').length == 1){
    var couponvue = new Vue({
        el:'.countvue',
        data:{
            count:0,
            info:[],
            list:[]
        },
        computed:{
        },
        methods:{
        },
        beforeCreate:function(){
            var that = this
            var _upData = {
                user_id:storageControl.getStorage('userId')
            }
            $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getcard',_upData,function(res){
                if(res.code != '0'){
                    that.info = res.data;
                    that.list = res.data1;
                    that.count = res.count;
                }else{
                    baseFn.popShow({
                        txt:res.info
                    })
                }
            },'json').complete(function(){
                baseFn.loading.call($('body'),'close')
            })
        },
        created:function(){
        }
    })
}
//快速预约
if($('.ordervue').length == 1){
    var ordervue = new Vue({
        el:'.ordervue',
        data:{
            orderid:'',
            user_id:'',
            user_name:'',
            user_gender:'',
            user_phone:'',
            hotelid : '',
            hotelname : '',
            doctor_id : '',
            doctor_name:'',
            time:'',
            date:'',
            udate:'',
            oldbooking_time:'',
            booking_type:9,
            isfirst:false,
            is_add:1,
            pt_id:'',
            pt_name:'',
            pt_age:0,
            pt_gender:0,
            pt_birthday:'',
            has_pt:true,
            can_changept:false
        },
        computed:{
            'booking_time':function(){
                if(this.time == ''){
                    return this.date
                }else{
                    return this.date+' '+this.time+':00'
                }
            },
            'pt_gender_txt':function(){
                return this.pt_gender == 0?'男':'女'
            },
            'oldbooking_time_txt':function(){
                if(this.oldbooking_time == ''){
                    return '无'
                }else{
                    var _timeArr = this.oldbooking_time.split('-')
                    return this.oldbooking_time == ''?'无':_timeArr[0]+'年'+_timeArr[1]+'月'+_timeArr[2].substring(0,2)+'日'+_timeArr[2].substring(3)
                }
                
            }
        },
        watch:{
            'user_name':function(val){
                storageControl.setStorage({ZuserName:val}) 
            },
            'user_gender':function(val){
                storageControl.setStorage({ZuserGender:val})
            },
            'user_phone':function(val){
                storageControl.setStorage({ZuserPhone:val})
            }
        },
        methods:{
            canchange:function(){
                if(this.can_changept){
                    storageControl.removeStorage('patientInfo') 
                    storageControl.setStorageS({'refreshs':true})
                    window.location.href="./selpatient.html"
                }    
            },
            showDoctorTimes:function(){
                var _txt=''
                if(!storageControl.isExitStorage('appointworker')){
                    _txt = '请您先选择医师'
                }
                if(!storageControl.isExitStorage('hotelid')){
                    _txt='请您先选择门店'
                }
                if(_txt != ''){
                    baseFn.popShow({
                        txt:_txt
                    })
                    return false
                }else{
                    // $('.ordertime').addClass('active');
                    // $('.mark').addClass('active')
                    // window.location.href="./selworkertime.html"
                    // storageControl.removeStorage('appointworker')
                    // storageControl.setStorageS({'refreshs':true})
                }
            },
            showTime:function(){
                var _txt=''
                if(!storageControl.isExitStorage('appointworker')){
                    _txt = '请您先选择医师'
                }
                if(!storageControl.isExitStorage('hotelid')){
                    _txt='请您先选择门店'
                }
                if(_txt != ''){
                    baseFn.popShow({
                        txt:_txt
                    })
                    return false
                }else{
                    $('.ordertime').addClass('active');
                    $('.mark').addClass('active')
                }
            },
            selDoctor:function(){
                window.location.href="./selworker.html"
                storageControl.setStorageS({'refreshs':true})
            },
            setNewHotel:function(){
                storageControl.removeStorage(['hotelid','appointworker'])
                storageControl.setStorageS({'refreshs':true})
            },
            setTips1:function(e){
                this.booking_type = e
                if(this.isfirst){
                    this.is_add = 1
                }else{
                    this.is_add = 0
                }
                
            },
            setTips2:function(e){
                this.is_add = e
            },
            check:function(){
                var _upData={
                    subclinic_id:this.hotelid,
                    user_id:this.user_id,
                    user_name:this.user_name,
                    user_gender:this.user_gender,
                    user_phone:this.user_phone,
                    doctor_id:this.doctor_id,
                    booking_time:this.udate
                }
                var _txt=''
                if(_upData.subclinic_id == ''){
                    _txt = '请选择具体门店';
                }else if(_upData.doctor_id == ''){
                    _txt = '您需要选择医师';
                }else if(_upData.booking_time == ''){
                    _txt = '您需要选择预约时间';
                }else if(_upData.user_id == ''){
                    _txt = '用户为空，请重新进入预约界面';
                }else if(_upData.user_name == ''){
                    _txt = '您需要填写用户名';
                }else if(_upData.user_phone == ''){
                    _txt = '您需要填写正确的手机号';
                }else if(!(/^[1][3,4,5,7,8][0-9]{9}$/.test(String(_upData.user_phone)))){
                    _txt = '您需要填写正确的手机号';
                }
                if(_txt != ''){
                    baseFn.popShow({
                        txt:_txt
                    })
                    return false
                }
                $.post('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/setbooking',_upData,function(res){
                    if(res.code == 1){
                        baseFn.popShow({
                            txt:'预约成功，我们店里给孩子准备丰富的玩具，请提前10分钟到店哦~',
                            ok:function(){
                                storageControl.removeStorage(['ZuserName','ZuserGender','ZuserPhone'])
                                window.location.assign("./index.html")
                            }
                        })
                    }else{
                        baseFn.popShow({
                            txt:res.info
                        })
                        
                    }
                    
                },'json')
            }
        },
        beforeCreate:function(){
            var _hotelcnt=window.localStorage.getItem('hotelid'),_workercnt=window.localStorage.getItem('appointworker')
            this.hotelid = ''
            this.hotelname = ''
            this.doctor_id = ''
            this.doctor_name = ''
            if(storageControl.isExitStorage('hotelid')){
                var _hotelid= _hotelcnt.split(',')[0],_hotelname= _hotelcnt.split(',')[1]
                this.hotelid = _hotelid
                this.hotelname = _hotelname
                if(storageControl.isExitStorage('appointworker')){
                    this.doctor_id = _workercnt.split(',')[0]
                    this.doctor_name = _workercnt.split(',')[1]
                }
            }
            var _userData={
                user_id:storageControl.getStorage('userId')
                // user_id:1
            }
            var that=this;
            $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getbookinginfo',_userData,function(res){
                if(res.code==1){
                    var _data = res.data
                    if(baseFn.notNull(_data.patientInfo)){
                        if(_data.patientInfo.length > 1){
                            that.can_changept = true;
                        }else{
                            that.can_changept = false;
                        }
                        if(baseFn.notNull(_data.bookingInfo)){
                            var _patientInfo = _data.patientInfo.filter(function(v){
                                return v.patient_id == _data.bookingInfo.patient_id
                            })[0]
                        }else{
                            var _patientInfo = _data.patientInfo[0]
                        }
                        if(storageControl.isExitStorage('patientInfo')){
                            _patientInfo = JSON.parse(storageControl.getStorage('patientInfo'))
                        } 
                        that.pt_age = _patientInfo.patient_age
                        that.has_pt = true;
                        that.pt_id = _patientInfo.patient_id
                        that.pt_name = _patientInfo.patient_name
                        that.pt_gender = _patientInfo.patient_gender
                        that.pt_birthday = _patientInfo.patient_birthday
                    }else{
                        that.has_pt = false;
                    }
                    if(baseFn.notNull(_data.bookingInfo)){
                        var _bookingInfo = _data.bookingInfo
                        var _username=_bookingInfo.user_name == null?'':_bookingInfo.user_name,_userphone=_bookingInfo.user_phone==null?'':_bookingInfo.user_phone;
                        // if(storageControl.isExitStorage('ZuserName')){
                        //     _username=storageControl.getStorage('ZuserName')
                        // }
                        // if(storageControl.isExitStorage('ZuserGender')){
                        //     _usergender = storageControl.getStorage('ZuserGender')
                        // }
                        // if(storageControl.isExitStorage('ZuserPhone')){
                        //     _userphone = storageControl.getStorage('ZuserPhone')
                        // }
                        // that.user_gender=_usergender;
                        that.user_id=_bookingInfo.user_id;
                        that.user_name=_username;
                        that.user_phone=_userphone;
                        that.booking_type = baseFn.notNull(_bookingInfo.booking_type)?_bookingInfo.booking_type:6,
                        that.oldbooking_time = baseFn.notNull(_bookingInfo.booking_time)?_bookingInfo.booking_time.substring(0,16):''
                    }else{
                        that.isfirst=true
                        baseFn.loading.call($('body'),'open')
                        $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getuser',_userData,function(res){},'json').complete(function(){
                            baseFn.loading.call($('body'),'close')
                            var _data = res.data
                            var _username=_data.user_name == null?'':_data.user_name,_userphone=_data.user_phone==null?'':_data.user_phone;
                            // if(storageControl.isExitStorage('ZuserName')){
                            //     _username=storageControl.getStorage('ZuserName')
                            // }
                            // if(storageControl.isExitStorage('ZuserGender')){
                            //     _usergender = storageControl.getStorage('ZuserGender')
                            // }
                            // if(storageControl.isExitStorage('ZuserPhone')){
                            //     _userphone = storageControl.getStorage('ZuserPhone')
                            // }
                            that.user_id=_data.user_id
                            that.user_name=_username;
                            // that.user_gender=_usergender;
                            that.user_phone=_userphone;
                        }).complete(function(){
                            baseFn.loading.call($('body'),'close')
                        })
                    }
                }else{
                    alert('数据错误！')
                }
                
                
            },'json').complete(function(){
                baseFn.loading.call($('body'),'close')
            })
        },
        created:function(){
            var _hotelcnt=window.localStorage.getItem('hotelid'),_workercnt=window.localStorage.getItem('appointworker')
            if(storageControl.isExitStorage('hotelid')){
                var _hotelid= _hotelcnt.split(',')[0],_hotelname= _hotelcnt.split(',')[1]
                this.hotelid = _hotelid
                this.hotelname = _hotelname
                if(storageControl.isExitStorage('appointworker')){
                    this.doctor_id = _workercnt.split(',')[0]
                    this.doctor_name = _workercnt.split(',')[1]
                }
            }
            // var _time = window.localStorage.getItem('time')
            //     if(_time != null && _time != ''){
            //         this.date=_time.split(',')[0]
            //         this.time=_time.split(',')[1]
            //     }else{
            //         this.date=''
            //         this.time=''
            //     }
        }
    })
}
if($('.seltimevue').length == 1){
    var selTimevue = new Vue({
        el:'.seltimevue',
        data:{
            tab:[],
            curtab:'0',
            seled:[[],[],[],[],[]],
            ho:[],
            sellist:[],
            curtime:0,
            acc:999,
            dateList:[]
        },
        computed:{
        },
        methods:{
            haveseled:function(e){ 
                return this.seled[this.curtab] && this.seled[this.curtab].some(function(val){
                    return val == e
                })
            },
            overTime:function(e){
                var _date = new Date();
                this.curtime = _date.getHours()
                if(this.curtab == 0 && this.curtime >= e){
                    return true
                }else{
                    return false
                }
            },
            selTime:function(e,ids){
                var _date = new Date();
                this.curtime = _date.getHours()
                if(this.curtab == '0'){
                    if(e <= this.curtime){
                        baseFn.popShow({
                            txt:'该时间已过期，其选择其他时间!',
                            markshow:true
                        })
                        return false
                    }
                }
                if(this.holiday == true){
                    return false
                }
                var nosel = this.seled[this.curtab] && this.seled[this.curtab].some(function(val){
                    return e == val
                })
                if(nosel){
                    return false
                }
                this.acc = ids
            },
            seltab:function(e){
                this.curtab = e
            },
            check:function(){
                if(this.acc!=999){
                    ordervue.time=this.sellist[Number(this.acc)];
                    ordervue.date=this.dateList[this.curtab].text;
                    ordervue.udate=this.dateList[this.curtab].date+' '+ordervue.time+':00';
                    $('.ordertime').removeClass('active')
                    $('.mark').removeClass('active')
                }else{
                    baseFn.popShow({
                        txt:'请选择正确的时间'
                    })
                }   
            }
        },
        computed:{
            holiday:function(){
                var that = this
                var _tim= this.ho.some(function(val){
                    return val == that.curtab
                })

                console.log(_tim)
                return _tim
            }
        },
        watch:{
            acc:function(val){
            },
            curtab:function(){
                this.acc=999
            },
        },
        beforeCreate:function(){
            var that=this
            if(storageControl.isExitStorage('hotelid')){
                var _hotelid = window.localStorage.getItem('hotelid').split(',')[0],_upDatas={subclinic_id:_hotelid}
                $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/getsubclinic',_upDatas,function(res){
                    if(res.code == 1){
                        var _end=Number(res.data.subclinic_end_time),_start=Number(res.data.subclinic_start_time)
                        for(var m = _start;m <= (_end-1);m++){
                            that.sellist.push(m)
                        }
                    }
                },'json')
            }
            if(storageControl.isExitStorage('appointworker')){
                var _doctorid = window.localStorage.getItem('appointworker').split(',')[0],_upDatas={doctor_id:_doctorid}
                $.get('http://wechat.xrtn.dmpp.net.cn/children/frontend/web/index.php?r=child/doctor',_upDatas,function(res){
                    if(res.code == 1){
                        that.seled=res.data;
                        that.ho=res.ho
                    }
                },'json')
            }
        },
        created:function(){
            var curdate = new Date();
            this.curtime = curdate.getHours()
            var _cnweekArr = ['周日','周一','周二','周三','周四','周五','周六'],step=86400000;
            var formatList=[]
            for(var i=0;i<5;i++){
                var _date = new Date(Date.parse(new Date()) + step*i)
                var _cday = _date.getDate(),_cmonth=_date.getMonth()+1,_cweek=_date.getDay(),cnweek = _cnweekArr[_cweek],cndate=_cmonth+'月'+_cday+'日'
                if(i==0){
                    cnweek = '今天';
                }else if(i==1){
                    cnweek = '明天'
                }
                formatList.push({id:i,tit:cnweek,text:cndate,date:curdate.getFullYear()+'-'+_cmonth+'-'+_cday})
            }
            this.dateList = formatList
        }
    })
}
$(function(){
    $('.mark').click(function(){
        $('.ordertime').removeClass('active')
        $(this).removeClass('active')
        $('.pop').removeClass('active')
    })
    // $('.wrapper').height(document.scrollingElement.clientHeight)
    //$('.mark').width(document.scrollingElement.clientWidth)
})
// function formatTimeSel(ndate){
//     var _cnweekArr = ['周日','周一','周二','周三','周四','周五','周六'],step=86400000;
//     var formatList=[]
//     for(var i=0;i<5;i++){
//         var _date = new Date(Date.parse(new Date()) + step*i)
//         console.log(_date)
//         var _cday = _date.getDate(),_cmonth=_date.getMonth()+1,_cweek=_date.getDay(),cnweek = _cnweekArr[_cweek],cndate=_cmonth+'月'+_cday+'日'
//         if(i==0){
//             cnweek = '今天';
//         }else if(i==1){
//             cnweek = '明天'
//         }
//         formatList.push({id:i,tit:cnweek,text:cndate})
//     }
//     return formatList
// }
